package leecode

import "math"

func largestAltitude(gain []int) int {
	result := math.MinInt64
	prefix := make([]int, len(gain)+1)
	for i := 0; i < len(gain); i++ {
		prefix[i+1] = prefix[i] + gain[i]
		result = max(result, prefix[i+1], prefix[i])
	}
	return result
}
